package com.taldh.mutlithread;

public class SynchronizedLock {

    private static int count = 0;

    public void incr() {
        synchronized (this) {
            count ++;
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 1000; i++) {
            new Thread(() -> new SynchronizedLock().incr()).start();
        }

        Thread.sleep(1000);

        System.out.println(count);
    }

}
